<%@taglib prefix = "c" uri = "http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix = "fmt" uri = "http://java.sun.com/jsp/jstl/fmt"%>
<%@taglib prefix = "fn" uri = "http://java.sun.com/jsp/jstl/functions"%>

<h3><fmt:message key = "task.executors"/></h3>

<div class = "messages"><jsp:include page = "/messages.jsp"/></div>

<div class = "links">	
<ul class = "navbar2">
   <li>
      <a class = "control" href = "leadexecutorui?_action=taskForm&request_id=${requestBean.id}">
         <fmt:message key = "Command.addTask"/>
      </a>      
   </li>
</ul>
</div>
   	
<table class = "regular">
   <thead>
      <tr>
      	 <th><a class="head" href="leadexecutorui?_action=executorsList&orderBy=N&order=${order}&request_id=${requestBean.id}">N</a></th>
         <th><a class="head" href="leadexecutorui?_action=executorsList&orderBy=executor&order=${order}&request_id=${requestBean.id}"><fmt:message key = "task.executor"/></a></th>
         <th><fmt:message key = "task.text"/></th>            
         <th><a class="head" href="leadexecutorui?_action=executorsList&orderBy=startdate&order=${order}&request_id=${requestBean.id}"><fmt:message key = "task.startdate"/></a></th>
         <th><a class="head" href="leadexecutorui?_action=executorsList&orderBy=approxenddate&order=${order}&request_id=${requestBean.id}"><fmt:message key = "task.approxenddate"/></a></th>
         <th><a class="head" href="leadexecutorui?_action=executorsList&orderBy=enddate&order=${order}&request_id=${requestBean.id}"><fmt:message key = "task.enddate"/></a></th>
         <th><a class="head" href="leadexecutorui?_action=executorsList&orderBy=status&order=${order}&request_id=${requestBean.id}"><fmt:message key = "task.status"/></a></th>
         <th><fmt:message key = "task.operations"/></th>
      </tr>
   </thead>
   
   <tbody>
   	<c:choose>
     <c:when test="${fn:length(tasksList) != 0}">
      <c:forEach var = "task" items = "${tasksList}">
      <tr>
      	<td><c:out value = "${task.id}"/></td>
        <td>
           <c:out value = "${task.executor.lastName}"/>&nbsp;
           <c:out value = "${task.executor.firstName}"/>           
        </td>
        
        <td class = "textField"><c:out value = "${fn:substring(task.text, 0, 200)}"/></td>        
        <td><fmt:formatDate value="${task.startDate}" pattern="dd.MM.yyyy"/></td>      
        <td><fmt:formatDate value="${task.approxEndDate}" pattern="dd.MM.yyyy"/></td>          
        <td><fmt:formatDate value="${task.endDate}" pattern="dd.MM.yyyy"/></td>        
        <td><c:out value = "${task.status.status}"/></td>        
        <td>
          <ul class = "navbar2">
            <li>
               <a href="leadexecutorui?_action=taskDetails&request_id=${requestBean.id}&task_id=${task.id}">
                 <fmt:message key = "Command.details"/>           
               </a>
            </li>
          </ul> 
        </td>
      </tr>
      </c:forEach>
      </c:when>
      <c:otherwise>
        <tr><td colspan = "8"><center><fmt:message key="emptyList"/></center></td></tr>
      </c:otherwise>     
      </c:choose>     
   </tbody>       
</table>

<div class="links">
<ul class = "navbar2">
   <li>
      <a class = "control" href = "leadexecutorui?_action=taskForm&request_id=${requestBean.id}">
         <fmt:message key = "Command.addTask"/>
      </a>      
   </li>
</ul>
</div>